// const ip_address = "8.137.123.185:8081";   
const ip_address = "www.gynshwechat.cn";
// www.gynshwechat.cn
// const ip_address = "127.0.0.1:8001";
const retitle = "https";
const ip_port = "8001";
const APIkey = "7IDBZ-7JDW7-BFQX4-HVPNI-YEVCO-JCFEY";

function getAllDays4Month(year, month){
  return new Promise((resolve, reject) => {
    wx.request({
      url: retitle+"://" + ip_address + "/book/getAllDays4Month?year="+year+"&month="+month,
      method: 'GET',
      header: {'Content-Type': 'application/json'},  // http 请求是 JSON 数据格式
      success: function (res) {
        resolve(res);
      },
      fail(err) {
        reject(err)
      }
    })
  })
}

function getAllDays4Month2(year, month){
  return new Promise((resolve, reject) => {
    wx.request({
      url: retitle+"://" + ip_address + "/book/getAllDays4Month2?year="+year+"&month="+month,
      method: 'GET',
      header: {'Content-Type': 'application/json'},  // http 请求是 JSON 数据格式
      success: function (res) {
        resolve(res);
      },
      fail(err) {
        reject(err)
      }
    })
  })
}

function getAllByAreaName(cityname,areaname) {
  return new Promise((resolve, reject) => {
    wx.request({
      // http://localhost:8001/institution/getByCityName?cityname=成都市
      url: retitle+"://"+ ip_address + "/institution/getAllByAreaName",
      // data: JSON.stringify(formData),  // 将 formData 转化成JSON对象
      method: 'POST',
      header: {
        'Content-Type':  'application/x-www-form-urlencoded'
      }, // http 请求是 JSON 数据格式
      data:{
        cityname:cityname,
        areaname:areaname
      },
      success: function (res) {
        resolve(res);
      },
      fail(err) {
        reject(err)
      }
    })
  });
}

function getInstByMapId(mapid) {
  return new Promise((resolve, reject) => {
    wx.request({
      // http://localhost:8001/institution/getByCityName?cityname=成都市
      url: retitle+"://"+ ip_address + "/institution/getInstByMapId",
      // data: JSON.stringify(formData),  // 将 formData 转化成JSON对象
      method: 'POST',
      header: {
        'Content-Type':  'application/x-www-form-urlencoded'
      }, // http 请求是 JSON 数据格式
      data:{
        mapid:mapid
      },
      success: function (res) {
        resolve(res);
      },
      fail(err) {
        reject(err)
      }
    })
  });
}

function getAllByAreaNameWithNot(cityname,areaname) {
  return new Promise((resolve, reject) => {
    wx.request({
      // http://localhost:8001/institution/getByCityName?cityname=成都市
      url: retitle+"://"+ ip_address + "/institution/getAllByAreaNameWithNot",
      // data: JSON.stringify(formData),  // 将 formData 转化成JSON对象
      method: 'POST',
      header: {
        'Content-Type':  'application/x-www-form-urlencoded'
      }, // http 请求是 JSON 数据格式
      data:{
        cityname:cityname,
        areaname:areaname
      },
      success: function (res) {
        resolve(res);
      },
      fail(err) {
        reject(err)
      }
    })
  });
}

function doneBook(bookid,managerid){
  return new Promise((resolve, reject) => {
    wx.request({
      url: retitle+"://" + ip_address + "/book/doneBook",
      method: 'POST',
      header:{
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      data:{
        bookid:bookid,
        managerid:managerid
      },
      success:(res)=>{
        resolve(res);
      },
      fail(err) {
        reject(err)
      }
    })
  })
}
     

function getAddressByKey(latitude, longitude) {
  return new Promise((resolve, reject) => {
    wx.request({
      url: "https://apis.map.qq.com/ws/geocoder/v1/?location=" + latitude + "," + longitude + "&key=" + APIkey + "&get_poi=1",
      method: 'GET',
      header: {
        'Content-Type': 'application/json'
      }, // http 请求是 JSON 数据格式
      success: function (res) {
        console.log("反地址解析成功")
        resolve(res);
      },
      fail(err) {
        reject(err)
      }
    })
  })
}

function getInstList(ACCESS_TOKEN, id) {
  return new Promise((resolve, reject) => {
    wx.request({
      url: retitle+"://" + ip_address + "/staff/getInstList",
      // url: "https://qyapi.weixin.qq.com/cgi-bin/department/list?access_token="+ACCESS_TOKEN+"&id="+ID,
      method: 'POST',
      header: {
        'Content-Type': 'application/x-www-form-urlencoded'
      }, // http 请求是 JSON 数据格式
      data:{
        accessToken : ACCESS_TOKEN,
        id:id
      },
      success: function (res) {
        console.log("反地址解析成功")
        resolve(res);
      },
      fail(err) {
        reject(err)
      }
    })
  })
}

function getMemberList(ACCESS_TOKEN, ID) {
  return new Promise((resolve, reject) => {
    wx.request({
      url: "https://qyapi.weixin.qq.com/cgi-bin/user/simplelist?access_token="+ACCESS_TOKEN+"&department_id="+ID,
      method: 'GET',
      header: {
        'Content-Type': 'application/json'
      }, // http 请求是 JSON 数据格式
      success: function (res) {
        console.log("反地址解析成功")
        resolve(res);
      },
      fail(err) {
        reject(err)
      }
    })
  })
}

function getMemberListDetail(ACCESS_TOKEN, ID) {
  return new Promise((resolve, reject) => {
    wx.request({
      url: "https://qyapi.weixin.qq.com/cgi-bin/user/list?access_token="+ACCESS_TOKEN+"&department_id="+ID,
      method: 'GET',
      header: {
        'Content-Type': 'application/json'
      }, // http 请求是 JSON 数据格式
      success: function (res) {
        console.log("反地址解析成功")
        resolve(res);
      },
      fail(err) {
        reject(err)
      }
    })
  })
}

function getaccessToken() {
  const accInfo = wx.getAccountInfoSync().miniProgram;
  return new Promise((resolve, reject) => {
    wx.request({
      url: retitle+"://" + ip_address + "/staff/getaccessToken",
      method: 'POST',
      header: {
        'Content-Type': 'application/x-www-form-urlencoded'
      }, // http 请求是 JSON 数据格式
      data:{
        appid : accInfo.appId
      },
      success: function (res) {
        console.log("反地址解析成功")
        resolve(res);
      },
      fail(err) {
        reject(err)
      }
    })
  })
}

function getaccessTokenqiye() {
  const accInfo = wx.getAccountInfoSync().miniProgram;
  return new Promise((resolve, reject) => {
    wx.request({
      url: retitle+"://" + ip_address + "/staff/getaccessTokenqiye",
      method: 'POST',
      header: {
        'Content-Type': 'application/x-www-form-urlencoded'
      }, // http 请求是 JSON 数据格式
      data:{
        appid : accInfo.appId
      },
      success: function (res) {
        console.log("反地址解析成功")
        resolve(res);
      },
      fail(err) {
        reject(err)
      }
    })
  })
}

function getSecret(){
  const accInfo = wx.getAccountInfoSync().miniProgram;
  return new Promise((resolve, reject) => {
    wx.request({
      url: retitle+"://" + ip_address + "/staff/getSecret",
      method: 'POST',
      header:{
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      data:{
        appid : accInfo.appId
      },
      success:(res)=>{
        resolve(res);
      },
      fail(err) {
        reject(err)
      }
    })
  });
}

function getBooksByInst(map_id,year,month,day){
  return new Promise((resolve, reject) => {
    wx.request({
      url: retitle+"://" + ip_address + "/book/getBooksByInst",
      method: 'POST',
      header:{
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      data:{
        map_id : map_id,
        year:year,
        month:month,
        day:day
      },
      success:(res)=>{
        resolve(res);
      },
      fail(err) {
        reject(err)
      }
    })
  });
}

function processBook(bookid,staffid){
  return new Promise((resolve, reject) => {
    wx.request({
      url: retitle+"://" + ip_address + "/staff/processBook",
      method: 'POST',
      header:{
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      data:{
        bookid : bookid,
        staffid:staffid
      },
      success:(res)=>{
        resolve(res);
      },
      fail(err) {
        reject(err)
      }
    })
  });
}

function getOpenid(code){
  const accInfo = wx.getAccountInfoSync().miniProgram;
  return new Promise((resolve, reject) => {
    wx.request({
      url: retitle+"://" + ip_address + "/user/getOpenid",
      method: 'POST',
      header:{
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      data:{
        code: code,
        appid : accInfo.appId
      },
      success:(res)=>{
        resolve(res);
      },
      fail(err) {
        reject(err)
      }
    })
  });
}

function submitStaff(openid,oanum,name,map_id,city,area){
  return new Promise((resolve, reject) => {
    wx.request({
      url: retitle+"://" + ip_address + "/staff/submitStaff",
      method: 'POST',
      header:{
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      data:{
        openid:openid,
        oanum:oanum,
        name:name,
        map_id:map_id,
        city:city,
        area:area
      },
      success:(res)=>{
        resolve(res);
      },
      fail(err) {
        reject(err)
      }
    })
  });
}

function judgeStaff(openid){
  return new Promise((resolve, reject) => {
    wx.request({
      url: retitle+"://" + ip_address + "/staff/judgeStaff",
      method: 'POST',
      header:{
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      data:{
        openid:openid
      },
      success:(res)=>{
        resolve(res);
      },
      fail(err) {
        reject(err)
      }
    })
  });
}

function getGroupAdmin(openid){
  return new Promise((resolve, reject) => {
    wx.request({
      url: retitle+"://" + ip_address + "/staff/getGroupAdmin",
      method: 'POST',
      header:{
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      data:{
        openid:openid
      },
      success:(res)=>{
        resolve(res);
      },
      fail(err) {
        reject(err)
      }
    })
  });
}

function getGroup(openid){
  return new Promise((resolve, reject) => {
    wx.request({
      url: retitle+"://" + ip_address + "/staff/getGroup",
      method: 'POST',
      header:{
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      data:{
        openid:openid
      },
      success:(res)=>{
        resolve(res);
      },
      fail(err) {
        reject(err)
      }
    })
  });
}

function getGroupDetail(openid,groupid){
  return new Promise((resolve, reject) => {
    wx.request({
      url: retitle+"://" + ip_address + "/staff/getGroupDetail",
      method: 'POST',
      header:{
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      data:{
        openid:openid,
        groupid:groupid
      },
      success:(res)=>{
        resolve(res);
      },
      fail(err) {
        reject(err)
      }
    })
  });
}


function judgeDoneFlag(openid,groupid){
  return new Promise((resolve, reject) => {
    wx.request({
      url: retitle+"://" + ip_address + "/staff/judgeDoneFlag",
      method: 'POST',
      header:{
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      data:{
        openid:openid,
        groupid:groupid
      },
      success:(res)=>{
        resolve(res);
      },
      fail(err) {
        reject(err)
      }
    })
  });
}

function getMemberAdmin(openid,groupid,date){
  return new Promise((resolve, reject) => {
    wx.request({
      url: retitle+"://" + ip_address + "/staff/getMemberAdmin",
      method: 'POST',
      header:{
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      data:{
        openid:openid,
        groupid:groupid,
        date:date
      },
      success:(res)=>{
        resolve(res);
      },
      fail(err) {
        reject(err)
      }
    })
  });
}

function getMember(openid,groupid){
  return new Promise((resolve, reject) => {
    wx.request({
      url: retitle+"://" + ip_address + "/staff/getMember",
      method: 'POST',
      header:{
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      data:{
        openid:openid,
        groupid:groupid
      },
      success:(res)=>{
        resolve(res);
      },
      fail(err) {
        reject(err)
      }
    })
  });
}

function getTopiclist(openid,groupid){
  return new Promise((resolve, reject) => {
    wx.request({
      url: retitle+"://" + ip_address + "/staff/getTopiclist",
      method: 'POST',
      header:{
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      data:{
        openid:openid,
        groupid:groupid
      },
      success:(res)=>{
        resolve(res);
      },
      fail(err) {
        reject(err)
      }
    })
  });
}

function getTopiclistAdmin(openid,groupid,date){
  return new Promise((resolve, reject) => {
    wx.request({
      url: retitle+"://" + ip_address + "/staff/getTopiclistAdmin",
      method: 'POST',
      header:{
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      data:{
        openid:openid,
        groupid:groupid,
        date:date
      },
      success:(res)=>{
        resolve(res);
      },
      fail(err) {
        reject(err)
      }
    })
  });
}

function submitForm(assesses){
  return new Promise((resolve, reject) => {
    wx.request({
      url: retitle+"://" + ip_address + "/staff/submitForm",
      method: 'POST',
      header:{
        'Content-Type': 'application/json'
      },
      data:{
        assesses:assesses
      },
      success:(res)=>{
        resolve(res);
      },
      fail(err) {
        reject(err)
      }
    })
  });
}


function submitForm2(data){
  return new Promise((resolve, reject) => {
    wx.request({
      url: retitle+"://" + ip_address + "/staff/submitForm2",
      method: 'POST',
      header:{
        'Content-Type': 'application/json'
      },
      data:{
        data:data
      },
      success:(res)=>{
        resolve(res);
      },
      fail(err) {
        reject(err)
      }
    })
  });
}

function clearAssess(openid,groupid,memberid){
  return new Promise((resolve, reject) => {
    wx.request({
      url: retitle+"://" + ip_address + "/staff/clearAssess",
      method: 'POST',
      header:{
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      data:{
        openid:openid,
        groupid:groupid,
        memberid:memberid
      },
      success:(res)=>{
        resolve(res);
      },
      fail(err) {
        reject(err)
      }
    })
  });
}

function getTopiclistDetail(openid,groupid,memberid){
  return new Promise((resolve, reject) => {
    wx.request({
      url: retitle+"://" + ip_address + "/staff/getTopiclistDetail",
      method: 'POST',
      header:{
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      data:{
        openid:openid,
        groupid:groupid,
        memberid:memberid
      },
      success:(res)=>{
        resolve(res);
      },
      fail(err) {
        reject(err)
      }
    })
  });
}

function getKHDetail(openid,groupid){
  return new Promise((resolve, reject) => {
    wx.request({
      url: retitle+"://" + ip_address + "/staff/getKHDetail",
      method: 'POST',
      header:{
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      data:{
        openid:openid,
        groupid:groupid
      },
      success:(res)=>{
        resolve(res);
      },
      fail(err) {
        reject(err)
      }
    })
  });
}


function getKHDetail4Single(openid,groupid,memberid){
  return new Promise((resolve, reject) => {
    wx.request({
      url: retitle+"://" + ip_address + "/staff/getKHDetail4Single",
      method: 'POST',
      header:{
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      data:{
        openid:openid,
        groupid:groupid,
        memberid:memberid
      },
      success:(res)=>{
        resolve(res);
      },
      fail(err) {
        reject(err)
      }
    })
  });
}

function openAssGroup(openid,groupid,date){
  return new Promise((resolve, reject) => {
    wx.request({
      url: retitle+"://" + ip_address + "/staff/openAssGroup",
      method: 'POST',
      header:{
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      data:{
        openid:openid,
        groupid:groupid,
        date:date
      },
      success:(res)=>{
        resolve(res);
      },
      fail(err) {
        reject(err)
      }
    })
  });
}

function closeAssGroup(openid,groupid,date){
  return new Promise((resolve, reject) => {
    wx.request({
      url: retitle+"://" + ip_address + "/staff/closeAssGroup",
      method: 'POST',
      header:{
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      data:{
        openid:openid,
        groupid:groupid,
        date:date
      },
      success:(res)=>{
        resolve(res);
      },
      fail(err) {
        reject(err)
      }
    })
  });
}

function getAssGroup(openid,groupid,date){
  return new Promise((resolve, reject) => {
    wx.request({
      url: retitle+"://" + ip_address + "/staff/getAssGroup",
      method: 'POST',
      header:{
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      data:{
        openid:openid,
        groupid:groupid,
        date:date
      },
      success:(res)=>{
        resolve(res);
      },
      fail(err) {
        reject(err)
      }
    })
  });
}

function getTopicsWithDetail(openid,memberid,groupid,selectdate){
  return new Promise((resolve, reject) => {
    wx.request({
      url: retitle+"://" + ip_address + "/staff/getTopicsWithDetail",
      method: 'POST',
      header:{
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      data:{
        openid:openid,
        memberid:memberid,
        groupid:groupid,
        date:selectdate
      },
      success:(res)=>{
        resolve(res);
      },
      fail(err) {
        reject(err)
      }
    })
  });
}

function extractReport(openid,groupid,date){
    let parameter = "?openid=" + openid + '&groupid=' + groupid + '&date=' + date;
    // 请求文件
    wx.showLoading({
      title: '导出报表中'
    })
    wx.downloadFile({
      url: retitle+"://" + ip_address + "/staff/extractReport" + parameter,
      success: function (res) {
        wx.hideLoading()
        console.log(res);
        const filePath = res.tempFilePath
        // 打开文件
        wx.openDocument({
          filePath: filePath,
          showMenu: true,
          success: function (res) {
            console.log('打开文档成功')
          }
        })
      },
      error: function(res) {
        wx.hideLoading()
      }
    })
}

function modifyTopic(openid,topicid,topic_desc,topic_type){
  return new Promise((resolve, reject) => {
    wx.request({
      url: retitle+"://" + ip_address + "/staff/modifyTopic",
      method: 'POST',
      header:{
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      data:{
        openid:openid,
        topicid:topicid,
        topic_desc:topic_desc,
        topic_type:topic_type
      },
      success:(res)=>{
        resolve(res);
      },
      fail(err) {
        reject(err)
      }
    })
  });
}


function addTopic(openid,groupid,date,topic_desc,topic_type){
  return new Promise((resolve, reject) => {
    wx.request({
      url: retitle+"://" + ip_address + "/staff/addTopic",
      method: 'POST',
      header:{
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      data:{
        openid:openid,
        groupid:groupid,
        date:date,
        topic_desc:topic_desc,
        topic_type:topic_type
      },
      success:(res)=>{
        resolve(res);
      },
      fail(err) {
        reject(err)
      }
    })
  });
}

function deleteTopic(openid,topicid){
  return new Promise((resolve, reject) => {
    wx.request({
      url: retitle+"://" + ip_address + "/staff/deleteTopic",
      method: 'POST',
      header:{
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      data:{
        openid:openid,
        topicid:topicid
      },
      success:(res)=>{
        resolve(res);
      },
      fail(err) {
        reject(err)
      }
    })
  });
}

function getTopic(openid,topicid){
  return new Promise((resolve, reject) => {
    wx.request({
      url: retitle+"://" + ip_address + "/staff/getTopic",
      method: 'POST',
      header:{
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      data:{
        openid:openid,
        topicid:topicid
      },
      success:(res)=>{
        resolve(res);
      },
      fail(err) {
        reject(err)
      }
    })
  });
}


function getPersonInfo(openid){
  return new Promise((resolve, reject) => {
    wx.request({
      url: retitle+"://" + ip_address + "/staffOa/getPersonInfo",
      method: 'POST',
      header:{
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      data:{
        openid:openid
      },
      success:(res)=>{
        resolve(res);
      },
      fail(err) {
        reject(err)
      }
    })
  });
}

function changePersonInfo(openid,mopenid,todoType,value){
  return new Promise((resolve, reject) => {
    wx.request({
      url: retitle+"://" + ip_address + "/staffOa/changePersonInfo",
      method: 'POST',
      header:{
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      data:{
        openid:openid,
        mopenid:mopenid,
        todoType:todoType,
        value:value
      },
      success:(res)=>{
        resolve(res);
      },
      fail(err) {
        reject(err)
      }
    })
  });
}

function getDaiban(openid,groupid,date){
  return new Promise((resolve, reject) => {
    wx.request({
      url: retitle+"://" + ip_address + "/staff/getDaiban",
      method: 'POST',
      header:{
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      data:{
        openid:openid,
        groupid:groupid,
        date:date
      },
      success:(res)=>{
        resolve(res);
      },
      fail(err) {
        reject(err)
      }
    })
  });
}

function getBooksByStaff(staffid,status){
  return new Promise((resolve, reject) => {
    wx.request({
      url: retitle+"://" + ip_address + "/staffUsr/getBooksByStaff",
      method: 'POST',
      header:{
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      data:{
        staffid:staffid,
        status:status
      },
      success:(res)=>{
        resolve(res);
      },
      fail(err) {
        reject(err)
      }
    })
  });
}

function dealbook(staffid,bookid){
  return new Promise((resolve, reject) => {
    wx.request({
      url: retitle+"://" + ip_address + "/staffUsr/dealbook",
      method: 'POST',
      header:{
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      data:{
        staffid:staffid,
        bookid:bookid
      },
      success:(res)=>{
        resolve(res);
      },
      fail(err) {
        reject(err)
      }
    })
  });
}

function getLigList(openid,oanum,status){
  return new Promise((resolve, reject) => {
    wx.request({
      url: retitle+"://" + ip_address + "/staffLg/getLigList",
      method: 'POST',
      header:{
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      data:{
        openid:openid,
        oanum:oanum,
        status:status
      },
      success:(res)=>{
        resolve(res);
      },
      fail(err) {
        reject(err)
      }
    })
  });
}

function submitLg(preLgInfo){
  return new Promise((resolve, reject) => {
    wx.request({
      url: retitle+"://" + ip_address + "/staffLg/submitLg",
      method: 'POST',
      header:{
        'Content-Type': 'application/json'
      },
      data:{
        preLgInfo:preLgInfo
      },
      success:(res)=>{
        resolve(res);
      },
      fail(err) {
        reject(err)
      }
    })
  });
}

function updateTix(openid,uid,tflag,oanum){
  return new Promise((resolve, reject) => {
    wx.request({
      url: retitle+"://" + ip_address + "/staffLg/updateTix",
      method: 'POST',
      header:{
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      data:{
        openid:openid,
        uid:uid,
        tflag:tflag,
        oanum:oanum
      },
      success:(res)=>{
        resolve(res);
      },
      fail(err) {
        reject(err)
      }
    })
  });
}

function getLigListWithTix(openid,oanum,tflag){
  return new Promise((resolve, reject) => {
    wx.request({
      url: retitle+"://" + ip_address + "/staffLg/getLigListWithTix",
      method: 'POST',
      header:{
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      data:{
        openid:openid,
        oanum:oanum,
        tflag:tflag
      },
      success:(res)=>{
        resolve(res);
      },
      fail(err) {
        reject(err)
      }
    })
  });
}

function addToNotes(openid,oanum,staffName){
  return new Promise((resolve, reject) => {
    wx.request({
      url: retitle+"://" + ip_address + "/staffLg/addToNotes",
      method: 'POST',
      header:{
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      data:{
        openid:openid,
        oanum:oanum,
        staffName:staffName
      },
      success:(res)=>{
        resolve(res);
      },
      fail(err) {
        reject(err)
      }
    })
  });
}


function updateLgStatus(openid,uid,status){
  return new Promise((resolve, reject) => {
    wx.request({
      url: retitle+"://" + ip_address + "/staffLg/updateLgStatus",
      method: 'POST',
      header:{
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      data:{
        openid:openid,
        uid:uid,
        status:status
      },
      success:(res)=>{
        resolve(res);
      },
      fail(err) {
        reject(err)
      }
    })
  });
}

function getLigDetail(openid,uid){
  return new Promise((resolve, reject) => {
    wx.request({
      url: retitle+"://" + ip_address + "/staffLg/getLigDetail",
      method: 'POST',
      header:{
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      data:{
        openid:openid,
        uid:uid
      },
      success:(res)=>{
        resolve(res);
      },
      fail(err) {
        reject(err)
      }
    })
  });
}

function modifyLg(lgplus){
  return new Promise((resolve, reject) => {
    wx.request({
      url: retitle+"://" + ip_address + "/staffLg/modifyLg",
      method: 'POST',
      header:{
        'Content-Type': 'application/json'
      },
      data:{
        lgplus:lgplus
      },
      success:(res)=>{
        resolve(res);
      },
      fail(err) {
        reject(err)
      }
    })
  });
}

function rollback(openid,uid,status){
  return new Promise((resolve, reject) => {
    wx.request({
      url: retitle+"://" + ip_address + "/staffLg/rollback",
      method: 'POST',
      header:{
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      data:{
        openid:openid,
        uid:uid,
        status:status
      },
      success:(res)=>{
        resolve(res);
      },
      fail(err) {
        reject(err)
      }
    })
  });
}

function deleteLg(openid,uid){
  return new Promise((resolve, reject) => {
    wx.request({
      url: retitle+"://" + ip_address + "/staffLg/deleteLg",
      method: 'POST',
      header:{
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      data:{
        openid:openid,
        uid:uid
      },
      success:(res)=>{
        resolve(res);
      },
      fail(err) {
        reject(err)
      }
    })
  });
}

module.exports = {
  getAllDays4Month:getAllDays4Month,
  getAllDays4Month2:getAllDays4Month2,
  getAllByAreaName:getAllByAreaName,
  doneBook: doneBook,
  getAddressByKey:getAddressByKey,
  getInstList:getInstList,
  getMemberList:getMemberList,
  getMemberListDetail:getMemberListDetail,
  getaccessTokenqiye:getaccessTokenqiye,
  getaccessToken:getaccessToken,
  getSecret:getSecret,
  getBooksByInst:getBooksByInst,
  processBook:processBook,
  getOpenid:getOpenid,
  submitStaff:submitStaff,
  judgeStaff:judgeStaff,
  getGroupAdmin:getGroupAdmin,
  getGroup:getGroup,
  getMember:getMember,
  getMemberAdmin:getMemberAdmin,
  getTopiclist:getTopiclist,
  getTopiclistAdmin:getTopiclistAdmin,
  submitForm:submitForm,
  submitForm2:submitForm2,
  clearAssess:clearAssess,
  getTopiclistDetail:getTopiclistDetail,
  openAssGroup:openAssGroup,
  closeAssGroup:closeAssGroup,
  getAssGroup:getAssGroup,
  getTopicsWithDetail:getTopicsWithDetail,
  extractReport:extractReport,
  modifyTopic:modifyTopic,
  addTopic:addTopic,
  deleteTopic:deleteTopic,
  getTopic:getTopic,
  getPersonInfo:getPersonInfo,
  changePersonInfo:changePersonInfo,
  getBooksByStaff:getBooksByStaff,
  dealbook:dealbook,
  getAllByAreaNameWithNot:getAllByAreaNameWithNot,
  getInstByMapId:getInstByMapId,
  getDaiban:getDaiban,
  submitLg:submitLg,
  getLigList:getLigList,
  updateTix:updateTix,
  getLigListWithTix:getLigListWithTix,
  addToNotes:addToNotes,
  updateLgStatus:updateLgStatus,
  getLigDetail:getLigDetail,
  modifyLg:modifyLg,
  rollback:rollback,
  deleteLg:deleteLg,
  getGroupDetail:getGroupDetail,
  judgeDoneFlag:judgeDoneFlag,
  getKHDetail:getKHDetail,
  getKHDetail4Single:getKHDetail4Single
}
